var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(t, e) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(t, e) {
        t.__proto__ = e;
    } || function(t, e) {
        for (var r in e) e.hasOwnProperty(r) && (t[r] = e[r]);
    })(t, e);
}, function(t, e) {
    function r() {
        this.constructor = t;
    }
    o(t, e), t.prototype = null === e ? Object.create(e) : (r.prototype = e.prototype, 
    new r());
}), a = this && this.__decorate || function(t, e, r, o) {
    var a, i = arguments.length, l = i < 3 ? e : null === o ? o = Object.getOwnPropertyDescriptor(e, r) : o;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) l = Reflect.decorate(t, e, r, o); else for (var n = t.length - 1; 0 <= n; n--) (a = t[n]) && (l = (i < 3 ? a(l) : 3 < i ? a(e, r, l) : a(e, r)) || l);
    return 3 < i && l && Object.defineProperty(e, r, l), l;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("PlayerModel"), s = e("PlayerMain"), c = cc._decorator, l = c.ccclass, d = c.property, u = function(e) {
    function t() {
        var t = null !== e && e.apply(this, arguments) || this;
        return t.player = null, t.numLabel = null, t.isAttack = !1, t;
    }
    return i(t, e), t.prototype.onLoad = function() {}, t.prototype.onEnable = function() {
        cc.sys.isMobile && (this.node.on(cc.Node.EventType.TOUCH_START, this.touchStartHandler, this), 
        this.node.on(cc.Node.EventType.TOUCH_END, this.touchEndHandler, this), this.node.on(cc.Node.EventType.TOUCH_CANCEL, this.touchCancelHandler, this));
    }, t.prototype.onDisable = function() {
        this.node.targetOff(this);
    }, t.prototype.touchStartHandler = function() {
        this.player && this.player.isStart && (this.player.model.type == r.ArmType.狙击枪 || this.player.model.type == r.ArmType.导弹枪 ? this.player.model.addBuffer(r.BufferType.瞄准) : this.player.model.type == r.ArmType.激光枪 && this.player.model.addBuffer(r.BufferType.蓄力), 
        this.isAttack = !0);
    }, t.prototype.touchEndHandler = function() {
        this.player && this.player.isStart && (this.player.model.type == r.ArmType.狙击枪 || this.player.model.type == r.ArmType.导弹枪 ? this.player.model.hasBuffer(r.BufferType.瞄准) && (this.player.model.removeBuffer(r.BufferType.瞄准), 
        this.player.doAttack()) : this.player.model.type == r.ArmType.激光枪 && this.player.model.hasBuffer(r.BufferType.蓄力) && (this.player.model.removeBuffer(r.BufferType.蓄力), 
        this.player.doAttack()), this.isAttack = !1);
    }, t.prototype.touchCancelHandler = function(t) {
        this.touchEndHandler(t);
    }, t.prototype.refreshLabel = function() {
        var t = this.player.getModel();
        0 < t.time ? (t = t.total - t.count, this.numLabel.node.color = 0 == t ? cc.Color.RED : cc.Color.WHITE, 
        this.numLabel.string = t.toString()) : (this.numLabel.fontSize = 40, this.numLabel.string = "∞");
    }, t.prototype.start = function() {}, t.prototype.update = function() {
        if (this.player && this.player.checkTarget(this.player)) {
            var t = this.player.findTargets();
            if (0 < t.length) for (var e in t) {
                if (this.player.isAttack(t[e])) {
                    this.player.target = t[e];
                    break;
                }
                this.player.target = null;
            } else this.player.target = null;
            this.player.updateAtkDir(this.player.target);
        }
        this.isAttack && this.player.doAttack(), this.refreshLabel();
    }, a([ d({
        type: s.default,
        displayName: "Player",
        tooltip: "操控角色"
    }) ], t.prototype, "player", void 0), a([ d(cc.Label) ], t.prototype, "numLabel", void 0), 
    a([ l ], t);
}(cc.Component);

n.default = u;